<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript" charset="utf-8"
	src="<%=basePath%>js/ueditor1_4_3-utf8-jsp/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8"
	src="<%=basePath%>js/ueditor1_4_3-utf8-jsp/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8"
	src="<%=basePath%>js/ueditor1_4_3-utf8-jsp/lang/zh-cn/zh-cn.js"></script>

<script>
   		window.UEDITOR_HOME_URL = "<%=basePath%>js/ueditor1_4_3-utf8-jsp/*";
    	var ue = UE.getEditor('editor');
    </script>
<link rel="stylesheet" href="<%=basePath%>admin/css/bootstrap.min.css" />
<link rel="stylesheet" href="<%=basePath%>admin/css/dashboard.css" />
<link rel="stylesheet" href="<%=basePath%>admin/css/dialog.css" />
</head>

<body>
	<!--上部导航栏start-->
	<nav class="navbar navbar-inverse navbar-fixed-top">
		<div class="container-fluid">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed"
					data-toggle="collapse" data-target="#navbar" aria-expanded="false"
					aria-controls="navbar">
					<span class="sr-only">Toggle navigation</span> <span
						class="icon-bar"></span> <span class="icon-bar"></span> <span
						class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="#">众筹管理平台</a>
			</div>
			<div id="navbar" class="navbar-collapse collapse">

				<ul class="nav navbar-nav navbar-right">
					<li><a href="<%=basePath%>/pages/index.action">首页</a></li>
					<li><a href="#">${admin.name}</a></li>
					<li><a href="#" title="修改个人资料和密码的页面">设置</a></li>
					<li><a href="#" title="退出登录">退出</a></li>
				</ul>
			</div>
		</div>
	</nav>
	<!--上部导航栏end-->
	<div class="container-fluid">
		<div class="row">
			<!--左侧导航栏start-->
			<div class="col-sm-3 col-md-2 sidebar">
				<ul class="nav nav-sidebar">
					<li><a href="<%=basePath%>/pages/index.action">首页</a></li>
				</ul>
				<ul class="nav nav-sidebar">
            <li><a href="<%=basePath %>Projects/mav.action">所有项目*</a></li>
            <li><a href="<%=basePath %>Projects/projecReview.action">项目审核</a></li>
            <li><a href="<%=basePath %>Projects/trackingList.action">项目跟踪</a></li>
            <li><a href="<%=basePath %>Projects/productComments.action">项目评论</a></li>
            <li><a href="<%=basePath %>Projects/classity.action">项目分类*</a></li>
            <li><a href="<%=basePath %>Projects/recommend.action">项目推荐</a></li>
          </ul>
          <ul class="nav nav-sidebar">
            <li><a href="<%=basePath %>pages/backReg.action">注册管理员</a></li>
            <!-- <li><a href="">用户资金</a></li>
            <li><a href="">用户日志</a></li> -->
            <!-- <li><a href="">实名审核</a></li> -->
          </ul>
				<ul class="nav nav-sidebar">
					<li class="active"><a href="<%=basePath%>news/list.action">新闻管理</a></li>
					 <li><a href="<%=basePath %>Projects/questionall.action">问题管理</a></li>
            <li><a href="<%=basePath %>adminLogin/adminList.action">管理用户</a></li>
            <!-- <li><a href="">管理日志</a></li> -->
				</ul>
			</div>
			<!--左侧导航栏end-->
			<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
				<h1 class="page-header">众筹项目分类</h1>

				<div class="panel panel-default"></div>
				<div class="panel panel-default">
					<div class="panel-heading">
						<div class="panel-title">
							项目分类列表 <a class="btn btn-primary"
								href="<%=basePath%>pages/addNews.action">添加</a>
						</div>
					</div>
					<div class="panel-body">

						<div class="table-responsive ">
							<table class="table table-striped table-bordered">
								<thead>
									<tr>
										<th>序号</th>
										<th>新闻标题</th>
										<th>新闻作者</th>
										<th>新闻关键字</th>
										<th>图片</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${findAllSplit}" var="news">
										<tr>
									<td>${news.id }</td>
											<td>${news.title }</td>
											<td>${news.author }</td>
											<td>${news.keyWords }</td>
											<td>${news.picture }</td>
											<td><a href="#" data-toggle="modal"
												data-target="#myModal"
												onclick="getTable(${news.id },'${news.title }','${news.author }','<fmt:formatDate value="${news.releaseTime }" type="both"/>','<fmt:formatDate value="${news.updateTime }" type="both"/>','${news.content }','${news.keyWords }','${news.picture}','${news.newsId}')">详情|修改</a>
												<a href="#" onclick="getdel(${news.id})">删除</a></td>
										</tr>
									</c:forEach>

								</tbody>
							</table>
						</div>

						<!--模态框-->
						<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
							aria-labelledby="myModalLabel" aria-hidden="true">
							<div class="modal-dialog">
								<div class="modal-content">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal"
											aria-hidden="true">&times;</button>
										<h4 class="modal-title" id="myModalLabel">分类详情</h4>
									</div>
									<div class="modal-body">
										<div class="form">
											<form class="form-validate form-horizontal"
												id="feedback_form" action="#" method="post"
												enctype="multipart/form-data">
												<div class="form-group ">
													<label for="id" class="control-label col-lg-2">序号<span
														class="required"> *</span></label>
													<div class="col-lg-10">
														<input class="form-control" id="id" name="id" type="text"
															readonly />
													</div>
												</div>

												<div class="form-group ">
													<label for="title" class="control-label col-lg-2">新闻标题<span
														class="required"> *</span></label>
													<div class="col-lg-10">
														<input class="form-control" id="title" name="title"
															type="text" />
													</div>
												</div>
												<div class="form-group ">
													<label for="author" class="control-label col-lg-2">新闻作者<span
														class="required"> *</span></label>
													<div class="col-lg-10">
														<input class="form-control" id="author" name="author"
															type="text" />
													</div>
												</div>

												<div class="form-group ">
													<label for="releaseTime" class="control-label col-lg-2">创建时间<span
														class="required"> *</span></label>
													<div class="col-lg-10">
														<input class="form-control" id="releaseTime"
															name="releaseTime" type="text" readonly />
													</div>
												</div>

												<div class="form-group ">
													<label for="updateTime" class="control-label col-lg-2">修改时间<span
														class="required"> *</span></label>
													<div class="col-lg-10">
														<input class="form-control" id="updateTime"
															name="updateTime" type="text" readonly />
													</div>
												</div>
												<div class="form-group ">
													<label for="content" class="control-label col-lg-2">新闻内容<span
														class="required"> *</span></label>
													<div class="col-lg-10">
														<!-- <input class="form-control" id="content" name="content"
															type="text" /> -->
														<textarea id="container" name="content"
															style="width: 465px; height: 300px; margin: 0 auto;">
														</textarea>
													</div>
												</div>

												<div class="form-group ">
													<label for="keyWords" class="control-label col-lg-2">新闻关键字<span
														class="required"> *</span></label>
													<div class="col-lg-10">
														<input class="form-control" id="keyWords" name="keyWords"
															type="text" />
													</div>
												</div>
												<div class="form-group ">
													<label for="picture" class="control-label col-lg-2">图片<span
														class="required"> *</span></label>
													<div class="col-lg-10">
														<input class="form-control" id="picture"
															name="picture" type="text" />
													</div>
												</div>
												<div class="form-group ">
													<label for="newsId" class="control-label col-lg-2">是否推荐<span
														class="required"> *</span></label>
													<div class="col-lg-10">
														<!-- <input class="form-control" id="newsId" name=newsId
															type="text" readonly /> -->
														<select class="form-control m-bot15" name="newsId"
															id="newsId">
															<option value="0">不推荐</option>
															<option value="1">推荐</option>
														</select>
													</div>
												</div>
												<div class="form-group" style="text-align: right;">
													<div class="col-lg-offset-2 col-lg-10">
														<button class="btn btn-primary" type="button" id="update"
															onclick="upDate()">保存</button>
														<button class="btn btn-default" type="reset">重置</button>
													</div>
												</div>
											</form>
											<script type="text/javascript">
  												// var ue = UE.getEditor("container");
  												var ue = UE.getEditor('container');//初始化对象
												/*
  												$(document).ready(function(){
														var ue = UE.getEditor('container');
														var proinfo=$("#container").val(222);
														//alert(proinfo+"++++");
														
														ue.ready(function() {//编辑器初始化完成再赋值
															ue.setContent(proinfo);  //赋值给UEditor
														});
														
													});
												*/
											</script>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="pager-info">
							<div>共有 ${findAllCount}条记录，第 ${currentPage}/${allPage} 页</div>
							<div>
								<ul class="pagination">
									<c:if test="${currentPage > 1}">
										<li><a
											href="<%=basePath %>news/list.action?currentPage=${currentPage-1}&lineSize=${lineSize}">上一页</a>
										</li>
									</c:if>
									<c:if test="${currentPage <= 1}">
										<li class="paginate_button previous disabled }"><a
											href="#">上一页</a></li>
									</c:if>

									<c:forEach begin="1" end="${allPage}" step="1" var="pageNum">
										<c:if test="${currentPage eq pageNum }">
											<li class="paginate_button active"><a
												href="<%=basePath %>news/list.action?currentPage=${pageNum}">${pageNum}</a></li>
										</c:if>
										<c:if test="${currentPage ne pageNum }">
											<li class="paginate_button"><a
												href="<%=basePath %>news/list.action?currentPage=${pageNum}">${pageNum}</a></li>
										</c:if>
									</c:forEach>
									<c:if test="${currentPage < allPage}">
										<li><a
											href="<%=basePath %>news/list.action?currentPage=${currentPage+1}&lineSize=${lineSize}">下一页</a>
										</li>
									</c:if>
									<c:if test="${currentPage >= allPage}">
										<li class="paginate_button previous disabled }"><a
											href="#">下一页</a></li>
									</c:if>
								</ul>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript"
		src="<%=basePath%>admin/js/jquery1.12.4.min.js"></script>
	<script type="text/javascript"
		src="<%=basePath%>admin/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>admin/js/countUp.js"></script>
	<script type="text/javascript" src="<%=basePath%>admin/js/dialog.js"></script>
	<script>
    function getTable(id,title,author,releaseTime,updateTime,content,keyWords,picture,newsId){
        document.getElementById("id").value=id;
        document.getElementById("title").value=title;
        document.getElementById("author").value=author;
        
        document.getElementById("releaseTime").value=releaseTime;
        document.getElementById("updateTime").value=updateTime;
        
        document.getElementById("container").value=content;
        
        document.getElementById("keyWords").value=keyWords;
        document.getElementById("picture").value=picture;
        document.getElementById("newsId").value=newsId;
        
        
		ue.ready(function() {//编辑器初始化完成再赋值
			ue.setContent(content);  //赋值给UEditor
		});
		
    }
     function getdel(id){
        javascript:$('body').dailog({type:'danger',title:'错误.',discription:'您确定要删除ID为'+id+'的数据吗?'},
            function(ret) { 
                if(ret.index===0){
                    window.location.href= "<%=basePath%>news/deleteNews.action?id="+id;
                };
            })
    }
     
     
     
     function upDate(){
    	//var form = new FormData(document.getElementById("feedback_form"));
   		  	$.ajax({
   			  url:"<%=basePath%>news/update.action",
                 type:'post',
                 dataType:'json',
                 data:$("#feedback_form").serialize(),//seralize
                 success:function(data){
                	 alert("++++" + data.msg);
                 },
                 error: function(){
     				alert("保存草稿失败!!!");
     			}
             });

     }
     
    
     
   <%--  function confirmDelete(id){
    	if (confirm("确定要删除码？")) {
    		//alert('发送删除请求，刷新页面（不要异步）');
    		window.location.href = "<%=basePath%>Projects/projectsTypeRemove.action?id="+id;
    	}
    	return false;
    } --%>
</script>

</body>
</html>